package com.yang.controller;


import com.yang.mapper.UnionsMapper;
import com.yang.pojo.Unions;
import com.yang.service.UnionsService;
import com.yang.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 朝阳
 * @since 2021-11-24
 */
@RestController
@RequestMapping("/unions")

public class UnionsController {
//    @Autowired
//    private UnionsService unionsService;
//
//    @PostMapping("/queryAllUnions")
//    public Result queryAllUnion() {
//        List<Unions> union = unionsService.list(null);
//        if (union != null) {
//            return new Result(100, "查询成功", union);
//        }
//        return new Result(200, "代码有问题请联系QQ：2655906529");
//    }
//
//    @PostMapping("/addOneUnions")
//    public Result addOneUnions(@RequestBody Unions unions) {
//        String regex = "^.{3,32}$";
//        if (unions.getUnionsname().matches(regex) && unions.getUnionsurl().matches(regex) && unions.getUnionscontact().matches(regex) && unions.getUnionsdocument().matches(regex)) {
//            unions.setUnionsname(unions.getUnionsname());
//            unions.setUnionsurl(unions.getUnionsurl());
//            unions.setUnionscontact(unions.getUnionscontact());
//            unions.setUnionsdocument(unions.getUnionsdocument());
//            boolean save = unionsService.save(unions);
//            if (save == true) {
//                return new Result(100, "插入成功", save);
//            } else {
//                return new Result(200, "代码有问题请联系QQ：2655906529");
//            }
//        }
//        return new Result(200, "格式错误");
//    }
//
//    @PostMapping("/updataOneUnions")
//    public Result updataOneUnions(@RequestBody Unions unions) {
//        String regex = "^.{3,32}$";
//        if (unions.getUnionsname().matches(regex) && unions.getUnionsurl().matches(regex) && unions.getUnionscontact().matches(regex) && unions.getUnionsdocument().matches(regex)) {
//            unions.setUnionsid(unions.getUnionsid());
//            unions.setUnionsname(unions.getUnionsname());
//            unions.setUnionsurl(unions.getUnionsurl());
//            unions.setUnionscontact(unions.getUnionscontact());
//            unions.setUnionsdocument(unions.getUnionsdocument());
//            boolean save = unionsService.updateById(unions);
//            if (save == true) {
//                return new Result(100, "插入成功", save);
//            } else {
//                return new Result(200, "代码有问题请联系QQ：2655906529");
//            }
//        }
//        return new Result(200, "格式错误");
//    }
//
//    @PostMapping("/deleteOneUnions")
//    public Result deleteOneUnions(@RequestBody Unions unions) {
//        unions.setUnionsid(unions.getUnionsid());
//        unions.setUnionsname(unions.getUnionsname());
//        unions.setUnionsurl(unions.getUnionsurl());
//        unions.setUnionscontact(unions.getUnionscontact());
//        unions.setUnionsdocument(unions.getUnionsdocument());
//        boolean save = unionsService.updateById(unions);
//        if (save == true) {
//            return new Result(100, "插入成功", save);
//        }
//        return new Result(200, "格式错误");
//    }

}

